/* 
 * Copyright [2018] [Alex/libo(liboms@hotmail.com)]
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.hyts.parser.config;

import org.xml.sax.ContentHandler;

/** 
 * @title ParseContentType.java  
 * @package com.hyts.parser.config  
 * @description 处理类的对象解析内容实体操作-类型
 * 				*ContentHandler操作的类划分：
 * 				(默认)BodyContentHandler:这个类采用XHTML输出的主体部分，并写入该内容到输出写入或输出流。然后重定向XHTML内容到另一个内容处理程序实例。
 * 				LinkContentHandler:这个类检测，并挑选XHTML文档的所有H-参考标签和转发那些使用类似网络爬虫工具。
 * 				TeeContentHandler:这个类可以帮助在同时使用多个工具。
 * @see TODO
 * @author libo/Alex
 * @email liboms@hotmail.com/liboware@163.com  
 * @date 2018年4月9日 
 * @version V1.0 
 */
public enum ParseContentType {

	/**  
	 * <p>采用XHTML输出的主体部分</p> 
	 * @fieldName BODY_CONTENT_HANDLER
	 * @fieldType ParseContentType
	 */ 
	BODY_CONTENT_HANDLER("org.apache.tika.sax.BodyContentHandler"){
		@Override
		public ContentHandler getInstance() {
			try {
				return (ContentHandler) Class.forName(this.getClassName()).newInstance();
			} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			return null;
		}
	},
	/**  
	 * <p>类似网络爬虫工具</p> 
	 * @fieldName LINK_CONTENT_HANDLER
	 * @fieldType ParseContentType
	 */ 
	LINK_CONTENT_HANDLER("org.apache.tika.sax.LinkContentHandler"){
		@Override
		public ContentHandler getInstance() {
			try {
				return (ContentHandler) Class.forName(this.getClassName()).newInstance();
			} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			return null;
		}		
	},
	/**  
	 * <p>这个类可以帮助在同时使用多个工具</p> 
	 * @fieldName TEE_CONTENT_HANDLER
	 * @fieldType ParseContentType
	 */ 
	TEE_CONTENT_HANDLER("org.apache.tika.sax.TeeContentHandler"){
		@Override
		public ContentHandler getInstance() {
				try {
					return (ContentHandler) Class.forName(this.getClassName()).newInstance();
				} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			return null;
		}
	};
	
	/**  
	 * <p>class类名称路径信息</p> 
	 * @fieldName className
	 * @fieldType String
	 */ 
	private String className;

	/**  
	 * @name className's getter method
	 * @param none
	 * @return className
	 */
	public String getClassName() {
		return className;
	}

	/**  
	 * @name className's setter method
	 * @param className
	 * @return void
	 */
	public void setClassName(String className) {
		this.className = className;
	}

	/**  
	 * @constructor：ParseContentType  
	 * @param className  
	 */ 
	private ParseContentType(String className) {
		this.className = className;
	}
	
	public abstract ContentHandler getInstance();

}
